﻿using System;
using Microsoft.Extensions.DependencyInjection;

namespace AspnetUtil.Web.Config.DI
{
    /// <summary>
    /// 标记 service,
    /// 默认的 scope 为 <see cref="ServiceLifetime.Scoped"/> 
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class ServiceAttribute : Attribute
    {
        /// <summary>
        /// 生命周期, 默认为  {@link ServiceLifetime.Scoped}
        /// </summary>
        public ServiceLifetime Lifetime { get; set; } = ServiceLifetime.Scoped;

        public ServiceAttribute(ServiceLifetime lifetime)
        {
            Lifetime = lifetime;
        }

        public ServiceAttribute()
        {
        }
    }
}